#import "Grapheur.h"

Grapheur::Grapheur(){
this->g_graphe = new Graphe("Graphe 1");
this->graphe = new Graphe("mon graphe");
this->g_molecule = new Molecule("Molecule 1");
this->molecule = new Molecule("ma molecule");
}

Grapheur::~Grapheur(){
	
}

void Grapheur::manip1(){
	cout<<"Graphe <: GGraphe<Graphe, Sommet, Arete>"<<endl;
	cout<<this->g_graphe->toStringComplet()<<this->graphe->toStringComplet()<<endl;
	cout<<"Molecule <: GGraphe<Molecule, Atome, Liaison>"<<endl;
	cout<<this->g_molecule->toStringComplet()<<this->molecule->toStringComplet()<<endl;
}

void Grapheur::manip2(){
	
	cout<<"Utilisation du self()"<<endl<<endl;
	graphe->newSommet("s1");
	cout<<graphe->getSommet(0)->toStringComplet()<<endl<<endl;
	graphe->newSommet("s2");
	cout<<graphe->getSommet(1)->toStringComplet()<<endl<<endl;
	graphe->newSommet("s3");
	cout<<graphe->getSommet(2)->toStringComplet()<<endl<<endl;
	cout<<graphe->toStringComplet()<<endl<<endl<<endl;
	
	molecule->newSommet("a1");
	cout<<molecule->getSommet(0)->toStringComplet()<<endl<<endl;
	molecule->newSommet("a2");
	cout<<molecule->getSommet(1)->toStringComplet()<<endl<<endl;
	molecule->newSommet("a3");
	cout<<molecule->getSommet(2)->toStringComplet()<<endl<<endl;
	cout<<molecule->toStringComplet()<<endl;
}

void Grapheur::manip3(){
	cout<<"Utilisation du dynamic_cast<X *>(this)"<<endl<<endl;
	cout<<graphe->toStringComplet()<<endl<<endl;
	Sommet * s = graphe->getSommet(0);
	s->deleteSommet();
	delete s;
	cout<<graphe->toStringComplet()<<endl<<endl;
	
	cout<<molecule->toStringComplet()<<endl<<endl;
	Atome * a = molecule->getSommet(0);
	a->deleteSommet();
	delete a;
	cout<<molecule->toStringComplet()<<endl<<endl;
}

void Grapheur::manip4(){
	cout<<"Utilisation du static_cat<X *>(this)"<<endl<<endl;
	cout<<graphe->toStringComplet()<<endl<<endl;
	graphe->newArete("_a1_", graphe->getSommet(0), graphe->getSommet(1));
	cout<<graphe->getArete(0)->toStringComplet()<<endl<<endl;
	cout<<graphe->toStringComplet()<<endl<<endl;
}

void Grapheur::manip5(){
	cout<<"Manipulation"<<endl<<endl;
	cout<<graphe->toStringComplet()<<endl<<endl;
	graphe->newSommet("s4");
	graphe->newSommet("s5");
	graphe->newSommet("s6");
	graphe->newArete("_a2_", graphe->getSommet(0), graphe->getSommet(2));
	graphe->newArete("_a3_", graphe->getSommet(0), graphe->getSommet(3));
	graphe->newArete("_a4_", graphe->getSommet(1), graphe->getSommet(3));
	cout<<endl<<endl<<graphe->toStringComplet()<<endl<<endl;
	cout<<"Suppression d'un sommet"<<endl<<endl;
	Sommet * s = graphe->getSommet(0);
	s->deleteSommet();
	cout<<graphe->toStringComplet()<<endl<<endl;
	
}
